package display.controller;

import display.WheelDisplay;
import display.structure.Belt;
import prefuse.action.ItemAction;
import prefuse.visual.VisualItem;

public class BeltTimmer extends ItemAction{
	private long maxTimeStep = WheelDisplay.MAX_TIMESTEP;
	private long  m_lasttime = -1;
	private Belt belt = null;

	public void run(double frac) {
		if ( m_lasttime == -1 )
            m_lasttime = System.currentTimeMillis()-20;
        long time = System.currentTimeMillis();
        long timestep = Math.min(maxTimeStep, time - m_lasttime);
        m_lasttime = time;
        belt.timmerBarPosition(timestep);
	}
	
	public BeltTimmer(String group, Belt belt) {
		this.belt = belt;
	}

	@Override
	public void process(VisualItem item, double frac) {
		
	}
}
